package com.easy.west.westclient.client;

import android.content.Context;

;

import com.easy.west.westclient.api.constacts.api.ConstactsApi;
import com.easy.west.westclient.api.constacts.api.ConstantsImpl;
import com.easy.west.westclient.api.department.api.DepartMentApi;
import com.easy.west.westclient.api.department.api.DepartMentImpl;
import com.easy.west.westclient.api.login.api.LoginApi;
import com.easy.west.westclient.api.login.api.LoginImpl;
import com.easy.west.westclient.api.meeting.api.MeetingApi;
import com.easy.west.westclient.api.meeting.api.MeetingImpl;
import com.easy.west.westclient.api.message.api.MessageApi;
import com.easy.west.westclient.api.message.api.MessageImpl;
import com.easy.west.westclient.api.push.api.PushApi;
import com.easy.west.westclient.api.push.api.PushImpl;
import com.easy.west.westclient.api.workplan.api.WorkPlanApi;
import com.easy.west.westclient.api.workplan.api.WorkPlanImpl;

import java.util.UUID;

/**
 * 连接客户端
 * 唯一识别码是给请求序号编号防止重复多次请求
 * 需要实现相关逻辑
 * Created by admin on 2018/5/16.
 */

public class WastClient implements LoginApi,WorkPlanApi,DepartMentApi,ConstactsApi,MeetingApi,PushApi,MessageApi
{
    private volatile static WastClient instance;
    private LoginImpl login;
    private WorkPlanImpl workPlan;
    private PushImpl push;
    private DepartMentImpl departMent;
    private ConstantsImpl constants;
    private MeetingImpl meeting;
    private MessageImpl message;
    private WastClient(Context context)
    {
        message = new MessageImpl(context);
        push = new PushImpl(context);
        meeting = new MeetingImpl(context);
        workPlan = new WorkPlanImpl(context);
        login = new LoginImpl(context);
        departMent = new DepartMentImpl(context);
        constants = new ConstantsImpl(context);
    }

    /**
     * 单例
     * @param context
     * @return
     */
    public static WastClient getInstance(Context context) {
        if (instance==null)
        {
            synchronized (WastClient.class)
            {
                if (instance==null)
                {
                    instance=new WastClient(context);
                }
            }
        }
        return instance;
    }

    /**
     * 登录
     * @param username
     * @param pwd
     * @return 唯一识别码
     */
    @Override
    public String login(String username, String pwd) {
        return login.login(username,pwd);
    }

    @Override
    public String finduser(int uid) {
        return login.finduser(uid);
    }

    /**
    * 创建日程
     * @param uid 用户id
     * @param start_time 开始时间
     * @param end_time 结束时间
     * @param content 内容
     * @return
             */
    @Override
    public String createWorkPlan(String start_time, String end_time, String content,String date,boolean top,long uid) {
        return workPlan.createWorkPlan(start_time,end_time,content,date,top,uid);
    }

    @Override
    public String findAllPlan(long uid) {
        return workPlan.findAllPlan(uid);
    }

    /**
     * 修改日程
     * @param start_time 开始时间
     * @param end_time 结束时间
     * @param content 内容
     * @param date
     * @param top
     * @param uid 用户id
     * @return
     */
    @Override
    public String changeWorkPlan(long id,String start_time, String end_time, String content, String date, boolean top, long uid) {
        return workPlan.changeWorkPlan(id,start_time,end_time,content,date,top,uid);
    }

    /**
     * 删除某日程
     * @param pid
     * @return
     */
    @Override
    public String delete(long pid) {
        return workPlan.delete(pid);
    }

    /**
     * 注释请前往接口查看
     * @return
     */
    @Override
    public String findalldepartMent() {

        return departMent.findalldepartMent();
    }

    @Override
    public String findallParentDepartMent() {
        return departMent.findallParentDepartMent();
    }

    @Override
    public String finddepartmentinfo(long did) {
        return departMent.finddepartmentinfo(did);
    }

    @Override
    public String findotherClassDepartMent(long fid) {
        return departMent.findotherClassDepartMent(fid);
    }

    @Override
    public String queryDepartment(String name) {
        return departMent.queryDepartment(name);
    }

    @Override
    public String findAllPeople() {
        return constants.findAllPeople();
    }

    @Override
    public String findPeopleinfo(long aid) {
        return constants.findPeopleinfo(aid);
    }

    @Override
    public String findPeopleByDepartMent(long did) {
        return constants.findPeopleByDepartMent(did);
    }

    @Override
    public String findConstactsisLink(long aid) {
        return constants.findConstactsisLink(aid);
    }

    @Override
    public String queryConstacts(String name) {
        return constants.queryConstacts(name);
    }

    @Override
    public String findConstactsbyuid(long uid) {
        return constants.findConstactsbyuid(uid);
    }

    /**
     * 注释见接口,别猜了
     * @param selectdate 时间
     * @param selecttime 时区范围
     * @param size 大小
     * @param vip 是否是vip
     * @return
     */
    @Override
    public String findMeetingRoomBy(String selectdate, int selecttime, int size, boolean vip) {
      return meeting.findMeetingRoomBy(selectdate,selecttime,size,vip);
    }

    @Override
    public String orderMeeting(long mrid, String title, String selectdate, int selecttime, long uid, long departmentid, int number, String leader, String starttime, String sit_card, String meeting_flag, boolean ispravite, String privatereason, String equipment
    ,String phone,String u_name) {
        return meeting.orderMeeting(mrid
                ,title,selectdate,selecttime,uid,departmentid,number,leader,starttime,sit_card,meeting_flag,ispravite,privatereason
                ,equipment,phone,u_name);
    }

    @Override
    public String findorderedMeet(int mrid) {
        return meeting.findorderedMeet(mrid);
    }

    /**
     *
     * @param notification_title 推送标题
     * @param notification_alert 推送展示内容
     * @param msg_content  推送消息实体
     * @param extraskey type
     * @param extrasvalue  typeinfo
     * @param alias 别名
     * @return
     */
    @Override
    public String push(String notification_title, String notification_alert, String msg_content, String extraskey, String extrasvalue, String... alias) {
        return push.push(notification_title
        ,notification_alert
        ,msg_content
        ,extraskey
        ,extrasvalue
        ,alias);
    }

    @Override
    public String findAllMessage(long uid) {
        return message.findAllMessage(uid);
    }

    @Override
    public String createMessage(String title, String content, String type, int userid, int isImportant) {
        return message.createMessage(title,content,type,userid,isImportant);
    }

    @Override
    public String readMessage(long isread) {
        return message.readMessage(isread);
    }

    public String findAllMessgae1(long uid)
    {
        return message.findAllMessage1(uid);
    }

    public String findAllMessage2(long uid)
    {
        return message.findAllMessage2(uid);
    }
}
